// var i;
// var $bundleConfig = require("./BundleConfig");
// var $eventManager = require("./EventManager");
// var $uIManager = require("./UIManager");
// var $timeUtils = require("./TimeUtils");
// var $evenType = require("./EvenType");
// var $playerDataManager = require("./PlayerDataManager");
// var $gameDataManager = require("./GameDataManager");
// var $gameGlobalVariable = require("./GameGlobalVariable");
// var $uIConfig_Home = require("./UIConfig_Home");
// var $baseModule = require("./BaseModule");
// var y = cc._decorator;
// var m = y.ccclass;
// var v = y.property;
// var b = y.inspector;
// var w = (function (e) {
//     function t() {
//         var t = (null !== e && e.apply(this, arguments)) || this;
//         t.wujintime = null;
//         t.wujincount = null;
//         t.wujinLock = null;
//         t.jiesuoTip = null;
//         return t;
//     }
//     __extends(t, e);
//     t.prototype.onEnable = function () {
//         $eventManager.EventMgr.addEventListener($evenType.EVENT_TYPE.GAME_TIAOZHAN_COUNT, this.initWuJinUi, this);
//         this.initWuJinUi();
//         if (-1 == $gameGlobalVariable.GameGlobalVariable.nowlevel) {
//             this.showTiaoZhan();
//             $gameGlobalVariable.GameGlobalVariable.nowlevel = 1;
//         }
//     };
//     t.prototype.onDisable = function () {
//         $eventManager.EventMgr.rmEventListener($evenType.EVENT_TYPE.GAME_TIAOZHAN_COUNT, this.initWuJinUi, this);
//     };
//     t.prototype.show = function () {
//         this.initWuJinUi();
//     };
//     t.prototype.hide = function () {};
//     t.prototype.initWuJinUi = function () {
//         this.jiesuoTip.string = "通关第" + $gameGlobalVariable.GameGlobalVariable.wujinunlockcount + "章解锁";
//         if ($gameDataManager.GameDataMgr.getNowMaxLevel() >= $gameGlobalVariable.GameGlobalVariable.wujinunlockcount) {
//             this.wujinLock.active = !1;
//         } else {
//             this.wujinLock.active = !0;
//         }
//         var e = $playerDataManager.PlayerDataMgr.getWuJinCount();
//         this.wujincount.string = "今日剩余" + e + "次";
//     };
//     t.prototype.showTiaoZhan = function () {
//         $uIManager.default.open($bundleConfig.BundleNames.Home, $uIConfig_Home.UIView_Home.UI_WuJinTiaoZhan);
//     };
//     t.prototype.showTip = function () {
//         $uIManager.default.open($bundleConfig.BundleNames.Home, $uIConfig_Home.UIView_Home.UI_ShuoMing);
//     };
//     t.prototype.update = function () {
//         this.wujintime.string = $timeUtils.default.secondsToHMS($timeUtils.default.getTimeUntilMidnight() / 1e3);
//     };
//     __decorate([v(cc.Label)], t.prototype, "wujintime", void 0);
//     __decorate([v(cc.Label)], t.prototype, "wujincount", void 0);
//     __decorate([v(cc.Node)], t.prototype, "wujinLock", void 0);
//     __decorate([v(cc.Label)], t.prototype, "jiesuoTip", void 0);
//     return __decorate([m], t);
// })($baseModule.default);
// exports.default = w;


// import {BundleNames} from "./BundleConfig";
// import {EventMgrInstance} from "./EventManager";
// import UIManager from "./UIManager";
// import TimeUtils from "./TimeUtils";
// import {EVENT_TYPE} from "./EvenType";
// import { PlayerDataMgr } from "./PlayerDataManager";
// import {GameDataMgr} from "./GameDataManager";
// import { GameGlobalVariable } from "./GameGlobalVariable";
// import { UIView_Home } from "./UIConfig_Home";
// import BaseModule from "./BaseModule";

// const { ccclass, property, inspector } = cc._decorator;

// /**
//  * 建议类名: WuJinModule
//  */
// @ccclass
// class Module_News extends BaseModule {
//     @property(cc.Label)
//     public wujintime: cc.Label | null = null;

//     @property(cc.Label)
//     public wujincount: cc.Label | null = null;

//     @property(cc.Node)
//     public wujinLock: cc.Node | null = null;

//     @property(cc.Label)
//     public jiesuoTip: cc.Label | null = null;

//     /**
//      * 当组件启用时调用
//      * 建议方法名: handleEnable
//      */
//     onEnable(): void {
//         EventMgrInstance.addEventListener(EVENT_TYPE.GAME_TIAOZHAN_COUNT, this.initWuJinUi, this);
//         this.initWuJinUi();
//         if (GameGlobalVariable.nowlevel === -1) {
//             this.showTiaoZhan();
//             GameGlobalVariable.nowlevel = 1;
//         }
//     }

//     /**
//      * 当组件禁用时调用
//      * 建议方法名: handleDisable
//      */
//     onDisable(): void {
//         EventMgrInstance.rmEventListener(EVENT_TYPE.GAME_TIAOZHAN_COUNT, this.initWuJinUi, this);
//     }

//     /**
//      * 显示无尽挑战UI
//      * 建议方法名: display
//      */
//     show(): void {
//         this.initWuJinUi();
//     }

//     /**
//      * 隐藏无尽挑战UI
//      * 建议方法名: conceal
//      */
//     hide(): void { }

//     /**
//      * 初始化无尽挑战UI
//      * 建议方法名: initializeWuJinUi
//      */
//     initWuJinUi(): void {
//         if (this.jiesuoTip) {
//             this.jiesuoTip.string = `通关第${GameGlobalVariable.wujinunlockcount}章解锁`;
//         }
//         if (this.wujinLock) {
//             this.wujinLock.active = GameDataMgr.getNowMaxLevel() < GameGlobalVariable.wujinunlockcount;
//         }
//         const remainingCount = PlayerDataMgr.getWuJinCount();
//         if (this.wujincount) {
//             this.wujincount.string = `今日剩余${remainingCount}次`;
//         }
//     }

//     /**
//      * 显示挑战UI
//      * 建议方法名: displayTiaoZhan
//      */
//     showTiaoZhan(): void {
//         UIManager.open(BundleNames.Home, UIView_Home.UI_WuJinTiaoZhan);
//     }

//     /**
//      * 显示提示UI
//      * 建议方法名: displayTip
//      */
//     showTip(): void {
//         UIManager.open(BundleNames.Home, UIView_Home.UI_ShuoMing);
//     }

//     /**
//      * 更新无尽挑战时间
//      * 建议方法名: refresh
//      */
//     update(): void {
//         if (this.wujintime) {
//             this.wujintime.string = TimeUtils.secondsToHMS(TimeUtils.getTimeUntilMidnight() / 1000);
//         }
//     }
// }

// export default Module_News;

import {BundleNames} from "./BundleConfig";
import {EventMgrInstance} from "./EventManager";
import UIManager from "./UIManager";
import TimeUtils from "./TimeUtils";
import {EVENT_TYPE} from "./EvenType";
import { PlayerDataMgr } from "./PlayerDataManager";
import {GameDataMgr} from "./GameDataManager";
import { GameGlobalVariable } from "./GameGlobalVariable";
import { UIView_Home } from "./UIConfig_Home";
import BaseModule from "./BaseModule";

const { ccclass, property, inspector } = cc._decorator;

/**
 * 建议类名: WuJinModule
 */
@ccclass
class ModuleNews extends BaseModule {
    @property(cc.Label)
    public wujintime: cc.Label | null = null;

    @property(cc.Label)
    public wujincount: cc.Label | null = null;

    @property(cc.Node)
    public wujinLock: cc.Node | null = null;

    @property(cc.Label)
    public jiesuoTip: cc.Label | null = null;

    /**
     * 当组件启用时调用
     * 建议方法名: handleEnable
     */
    onEnable(): void {
        EventMgrInstance.addListener(EVENT_TYPE.GAME_TIAOZHAN_COUNT, this.initializeWuJinUI, this);
        this.initializeWuJinUI();
        if (GameGlobalVariable.nowlevel === -1) {
            this.displayTiaoZhan();
            GameGlobalVariable.nowlevel = 1;
        }
    }

    /**
     * 当组件禁用时调用
     * 建议方法名: handleDisable
     */
    onDisable(): void {
        EventMgrInstance.removeListener(EVENT_TYPE.GAME_TIAOZHAN_COUNT, this.initializeWuJinUI, this);
    }

    /**
     * 显示无尽挑战UI
     * 建议方法名: display
     */
    show(): void {
        this.initializeWuJinUI();
    }

    /**
     * 隐藏无尽挑战UI
     * 建议方法名: conceal
     */
    hide(): void { }

    /**
     * 初始化无尽挑战UI
     * 建议方法名: initializeWuJinUi
     */
    initializeWuJinUI(): void {
        // 更新解锁提示标签
        if (this.jiesuoTip) {
            this.jiesuoTip.string = `通关第${GameGlobalVariable.wujinunlockcount}章解锁`;
        }

        // 更新无尽锁节点状态
        if (this.wujinLock) {
            this.wujinLock.active = GameDataMgr.getCurrentMaxLevel() < GameGlobalVariable.wujinunlockcount;
        }

        // 获取并更新无尽挑战次数
        const remainingCount = PlayerDataMgr.getWuJinCount();
        if (this.wujincount) {
            this.wujincount.string = `今日剩余${remainingCount}次`;
        }
    }

    /**
     * 显示挑战UI
     * 建议方法名: displayTiaoZhan
     */
    displayTiaoZhan(): void {
        UIManager.open(BundleNames.Home, UIView_Home.UI_WuJinTiaoZhan);
    }

    /**
     * 显示提示UI
     * 建议方法名: displayTip
     */
    displayTip(): void {
        UIManager.open(BundleNames.Home, UIView_Home.UI_ShuoMing);
    }

    /**
     * 更新无尽挑战时间
     * 建议方法名: refresh
     */
    update(): void {
        if (this.wujintime) {
            // 每次 update 时更新剩余时间
            this.wujintime.string = TimeUtils.convertSecondsToHMS(TimeUtils.getMillisecondsUntilMidnight() / 1000);
        }
    }
}

export default ModuleNews;